package com.kun.demo03;


import org.junit.Test;

//练习守护线程
public class TestDaemon {

    @Test
    public void testDaemon() throws InterruptedException {
        // 结论：最后虚拟机正常关闭，不会等待守护线程执行完毕

        Thread thread_god = new Thread(() -> {
            while (true) {
                System.out.println("守护线程持续启动");
            }
        });
        thread_god.setDaemon(true);
        thread_god.start();

        Thread thread_common = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.println("普通线程执行");
            }
        });
        thread_common.start();


    }
}
